<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core" template="/WEB-INF/layouts/standard.xhtml">
	<ui:define name="content">
		<p:growl id="msg"/>
		<p:panel header="Add new tenant">
			<h:form>
				<h:outputLabel value="Please enter tenant name:  " />
				<p:inputText id="tenant" value="#{tenantWizard.tenant}" required="true" requiredMessage="Please enter new tenant name!"
					disabled="#{tenantWizard.created}">
					<p:ajax event="keyup" update=":msg,btn" listener="#{tenantWizard.validate}" />
				</p:inputText>
				<p:commandButton id="btn" value="Create Tenant" disabled="#{!tenantWizard.valid and tenantWizard.created}"
					actionListener="#{tenantWizard.createTenant}" update="tenant,btn,:newuser,:msg" />
				<p:ajaxStatus style="width:16px;height:16px;">
					<f:facet name="start">
						<h:graphicImage library="images" name="ajax-loader.gif" />
					</f:facet>

					<f:facet name="complete">
						<h:outputText value="" />
					</f:facet>
				</p:ajaxStatus>
			</h:form>
		</p:panel>
		<p:panel  id="newuser" visible="#{tenantWizard.created}" header="Add new user">
			<h:form>
			<h:panelGrid border="1" columns="2">

				<h:outputLabel value="Full name" />
				<p:inputText value="#{tenantWizard.user.fullName}" immediate="true" required="true" requiredMessage="Give full name" />

				<h:outputLabel value="Email" />
				<p:inputText value="#{tenantWizard.user.email}" />

				<h:outputLabel for="un" value="User name" />
				<p:inputText id="un" value="#{tenantWizard.user.userName}" />

				<h:outputLabel value="Password" />
				<p:password match="confpw" value="#{tenantWizard.user.password}" label="Password 1" required="true"/>

				<h:outputLabel value="Confirm pasword" />
				<p:password id="confpw" required="true"  value="#{tenantWizard.user.password}" label="Password 2"/>

				<p:commandButton value="Save" actionListener="#{tenantWizard.saveUser}" update=":msg"></p:commandButton>

			</h:panelGrid>
			</h:form>
		</p:panel>

	</ui:define>
</ui:composition>
